package com.powernode.feign.fallbackfactory;

import com.powernode.domain.MemberAddr;
import com.powernode.feign.OrderMemberFeign;
import com.powernode.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @create: 2024/7/20
 * @author: gyhe10
 * @description:
 **/

@Component
@Slf4j
public class OrderMemberFeignFallbackFactory implements FallbackFactory<OrderMemberFeign> {

    @Override
    public OrderMemberFeign create(Throwable cause) {
        return new OrderMemberFeign() {
            @Override
            public Result<MemberAddr> getMemberAddrById(Long addrId) {
                log.error("调用会员服务中根据地址ID查询会员收货地址的接口失败，原因：{}", cause.getMessage());
                return null;
            }

            @Override
            public Result<String> getNickNameByOpenId(String openId) {
                log.error("调用会员服务中根据openId查询会员昵称的接口失败，原因：{}", cause.getMessage());
                return null;
            }

            @Override
            public Result<MemberAddr> getMemberDefaultAddrByOpenId(String openId) {
                log.error("调用会员服务中根据openId查询会员默认收货地址的接口失败，原因：{}", cause.getMessage());
                return null;
            }
        };
    }
}
